
 import pick from 'lodash.pick'
 import { deleteAction, putAction,downFile,httpAction } from '@/api/manage'

const yaodianMinxin = {
  data(){
    return {
        selectValue:'',
        modalvisible:false,
        gyscolumns:[],
        codeurls:'',
        yaodianObj:{},
        modalvisibleDetail:false,
        selectdomshow:false
        // 最多显示通知的数量
       ,maxNotifications: 3
       // 当前显示的通知数量
       ,currentNotifications: 0
    }
  },
  destroyed(){
    //删除 之前路由里所有的 提示弹窗
    this.clearAllWarining()
  },
  computed: {
    modalProps() {
        return Object.assign({
          valueKey: 'id',
          multiple: false,
          name: '药品',
          displayKey: 'code',
          returnKeys: ['id', 'code'],
          listUrl: '',
          columns: []
        }, {})
      },
  },
  created(){
   
  },
  methods:{
    handleCatalogOk(){
      this.loadData()
    },
    //医保目录添加
    handleCatalogAdd(){
      var record = {}
      record.project = this.keyIndex
      this.$refs.micodeModal.edit(record)
      
    },
    clearAllWarining(){
      //删除 之前路由里所有的 提示弹窗
      $('.ant-notification .ant-notification-notice').remove();
      this.currentNotifications = 0
    },
    // 提示信息定制
    sendNotification(content,title='提示') {
        var that = this;
        console.log(this.currentNotifications,'currentNotificationscurrentNotifications')
        if (this.currentNotifications >= this.maxNotifications) {
          // 达到最大通知数量，不再发送
          this.$notification.warning({
            message: '提示',
            description: '错误提示信息已达到' + this.maxNotifications + '个 ，请先处理已提示的错误.',
            // duration: 5,
          });
        } else {
          // 发送通知，并增加当前通知数量
        //   const key = `notification-${this.currentNotifications}`;
        this.$notification.error({
            // key,
            duration:null,
            message: title,
            description: content,
            onClose:function(){
                that.currentNotifications--;
            }
          });
          this.currentNotifications++;
        }
    },
    handleAdd: function () {
      this.$refs.modalForm.add();
      this.$refs.modalForm.title = "新增";
      this.$refs.modalForm.YXSdisableSubmit = false;
    },
    handleEdit: function (record) {
      this.$refs.modalForm.edit(record);
      this.$refs.modalForm.title = "编辑";
      this.$refs.modalForm.disableSubmit = false;
      if(record.saleFlag+'' === '1'){
        this.$refs.modalForm.YXSdisableSubmit = true; 
      }else{
        this.$refs.modalForm.YXSdisableSubmit = false;
      }
    },
    bizValChangeDetail(val){
        if(val && val.length){
            
            this.resetCode(val[0])
        }
    },
    okDetail(records){
        console.log(records,'okDetail');
        this.haocaiObj.listUrl = 'wh/medicalConsumable/miDetailSearch?miConsumableCode='+records.medicalCatalogCode,
        this.selectdomshow = true;
        this.$nextTick(function(){
          this.modalvisibleDetail = true
        })
    },
    //重新对照编码
    handleSetCode(records){
        this.yaodianObj = records
        this.selectValue = records.name
        this.modalvisible = true
    },
    bizValChange(val){
       console.log(val)
       if(val && val.length){
        this.resetCode(val[0])
       }
       
    },
    resetCode(infos){
        var that = this;
        if(!this.codeurls){
            this.$message.error('没有设置codeurls属性')
            return
        }
        var pamas = {
            id:this.yaodianObj.id,
            "medicalCatalogCode": infos.medicalCatalogCode,
            "medicalCatalogName": infos.medicalCatalogName,
        }
        putAction(this.codeurls, pamas).then((res) => {
            if (res.success) {
                this.modalvisible = false;
                this.clearAllWarining()
                this.loadData()
            }else{
                this.sendNotification(res.message)
            }
        });
    }
  }
}

export  { yaodianMinxin }